<?$this->load->view('admin/header');?>

<!-- Content Area -->
<div id="middlepart">
    <!-- Left column -->
    <div id="leftcolumnfull">
        <h1>Post Management</h1>

        <?=form_open($this->uri->uri_string(), array('name'=>'post_form'));?>

        <?$this->load->view('admin/system_messages');?>

        <div id="container-1">
            <ul>
                <li><a href="#fragment-7"><span>Content</span></a></li>
                <li><a href="#fragment-9"><span>Categories</span></a></li>
                <li><a href="#fragment-10"><span>Options</span></a></li>
                <li><a href="#" onclick="document.post_form.submit();"><span>Save This Post</span></a></li>
            </ul>
            <div id="fragment-7">

                <h4>Title</h4>
                <input type="text" class="medium" name="title" value="<?=$this->validation->title;?>" />

                <br />

                <h4>Excerpt</h4>
                <textarea name="excerpt" rows="10" id="post_excerpt" style="width: 95%;"><?=$this->validation->excerpt;?></textarea>

                <br />

                <h4>Extended</h4>
                <textarea name="extended" rows="10" id="post_extended" style="width: 95%;"><?=$this->validation->extended;?></textarea>

                <br />

                <a class="submit" href="#" onclick="document.post_form.submit();">submit</a> <a class="reset" href="#">cancel</a>

            </div>

            <div id="fragment-9">

                <select name="category_id[]" multiple size="10" style="width: 100%;">
                    <?foreach ($this->mdl_categories->get() as $category) {?>
                    <option value="<?=$category->category_id;?>" <?if (($this->validation->category_id AND in_array($category->category_id, $this->validation->category_id)) OR (!$this->validation->category_id AND $category->is_default)) {?>selected<?}?>><?=$category->category;?></option>
                    <?}?>
                </select>

            </div>

            <div id="fragment-10">

                <label>Date: </label>

                <select name="month">
                    <?for ($x = 1; $x <= 12; $x++) {?>
                    <option <?if (($this->validation->date AND date('m', $this->validation->date) == str_pad($x, 2, '0', STR_PAD_LEFT)) OR (!$this->validation->date AND date('m', time()) == str_pad($x, 2, '0', STR_PAD_LEFT))) {?>selected<?}?>><?=str_pad($x, 2, '0', STR_PAD_LEFT);?></option>
                    <?}?>
                </select>

                <select name="day">
                    <?for ($x = 1; $x <= 31; $x++) {?>
                    <option <?if (($this->validation->date AND date('d', $this->validation->date) == str_pad($x, 2, '0', STR_PAD_LEFT)) OR (!$this->validation->date AND date('d', time()) == str_pad($x, 2, '0', STR_PAD_LEFT))) {?>selected<?}?>><?=str_pad($x, 2, '0', STR_PAD_LEFT);?></option>
                    <?}?>
                </select>

                <select name="year">
                    <?for ($x = 2000; $x <= 2020; $x++) {?>
                    <option <?if (($this->validation->date AND date('Y', $this->validation->date) == $x) OR (!$this->validation->date AND date('Y', time()) == $x)) {?>selected<?}?>><?=$x;?></option>
                    <?}?>
                </select>

                <br />

                <label>Time: </label>
                <select name="hour">
                    <?for ($x = 1; $x <= 24; $x++) {?>
                    <option <?if (($this->validation->date AND date('G', $this->validation->date) == $x) OR (!$this->validation->date AND date('G', time()) == $x)) {?>selected<?}?>><?=$x;?></option>
                    <?}?>
                </select>

                <select name="minute">
                    <?for ($x = 0; $x <= 59; $x++) {?>
                    <option <?if (($this->validation->date AND date('i', $this->validation->date) == str_pad($x, 2, '0', STR_PAD_LEFT)) OR (!$this->validation->date AND date('i', time()) == str_pad($x, 2, '0', STR_PAD_LEFT))) {?>selected<?}?>><?=str_pad($x, 2, '0', STR_PAD_LEFT);?></option>
                    <?}?>
                </select>

                <br />

                <label>Author: </label>
                <select name="user_id">
                    <?foreach ($this->mdl_users->get_authors() as $author) {?>
                    <option value="<?=$author->user_id;?>" <?if(!$this->validation->user_id AND $author->user_id == $this->session->userdata('user_id') OR ($this->validation->user_id == $author->user_id)) {?>selected<?}?>><?=$author->display_name;?></option>
                    <?}?>
                </select>

                <br />

                <label>Published: </label>
                <input type="checkbox" name="published" value="1" <?if($this->validation->published) {?>checked<?}?>>

                <br />

                <label>Make Sticky: </label>
                <input type="checkbox" name="is_sticky" value="1" <?if($this->validation->is_sticky) {?>checked<?}?>>

                <br />

                <label>Allow Comments: </label>
                <input type="checkbox" name="allow_comments" value="1" <?if($this->validation->allow_comments) {?>checked<?}?>>

            </div>

        </div>

        </form>

        <br />
    </div>
    <!-- Left Column -->

</div>
<!-- Content -->

<?$this->load->view('admin/footer');?>